package com.likerSai;

/**
 * 整数反转
 *
 * @author sun.ye
 * @since 2021-04-27 20:44
 */
public class IntReverse {


    public static void main(String[] args) {
        int a = rInt(-2147483648);
        System.out.println(a);
    }
    public int reverse(int x) {

        return x;

    }



    public static int rInt(int x){

        int result = 0;
        while (x != 0){
            if (result > Integer.MAX_VALUE / 10 || (result == Integer.MAX_VALUE && x % 10 > 7)){
                return 0;
            }
            if (result < Integer.MIN_VALUE / 10 || (result == Integer.MIN_VALUE && x % 10 < -8)){
                return 0;
            }
            result = result * 10 + x % 10;
            x = x / 10;

        }
        return result;
    }

}

